package com.tgy.MyFlowable.workflow.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ctsi.core.common.util.StringUtil;
import com.ctsi.core.database.entity.Search;
import com.ctsi.core.database.util.PageUtil;
import com.ctsi.workflow.entity.FlwDraft;
import com.ctsi.workflow.mapper.FlwDraftMapper;
import com.ctsi.workflow.service.IFlwDraftService;
import org.springframework.stereotype.Service;

/**
 * 申请草稿表 服务实现类
 *
 * @version 1.0
 * @author: wang xiao xiang
 * @date: 2021/8/8 19:31
 */
@Service
public class FlwDraftServiceImpl extends ServiceImpl<FlwDraftMapper, FlwDraft> implements IFlwDraftService {

    @Override
    public IPage<FlwDraft> listPage(Search search) {
        LambdaQueryWrapper<FlwDraft> queryWrapper = Wrappers.lambdaQuery();
        if (StringUtil.isNotBlank(search.getKeyword())) {
            queryWrapper.like(FlwDraft::getId, search.getKeyword());
        }
        queryWrapper.orderByDesc(FlwDraft::getCreateTime);
        return this.baseMapper.selectPage(PageUtil.getPage(search), queryWrapper);
    }
}
